#include "Common/AutoSingleton.hh"
#include "Common/Logging.hh"


#include <boost/logging/format.hpp>
#include <boost/logging/format/formatter/high_precision_time.hpp>
#include <boost/logging/format/formatter/tags.hpp>
#include <boost/logging/format/named_write.hpp>

namespace _bl = boost::logging;

BOOST_DEFINE_LOG_FILTER( g_log_filter, Common::Logger::log_use::filter ) 
BOOST_DEFINE_LOG( g_l, Common::Logger::log_use::logger ) 

using namespace Common;

void Logger::_initialize( )
{
	g_l()->writer().add_formatter(
			_bl::formatter::named_spacer( "%time% (T%thread%) " )
				.add( "thread", _bl::formatter::thread_id() )
				.add( "time", _bl::formatter::high_precision_time( "$hh:$mm:$ss.$micro" ) )
			);
	g_l()->writer().add_formatter( _bl::formatter::append_newline() );

	// g_l()->writer().add_destination( destination::cout() );
	g_l()->writer().add_destination( _bl::destination::dbg_window() );
	// g_l()->writer().add_destination( destination::file("out.txt") );
	
	g_l()->mark_as_initialized();
}
